const superagent = require("superagent");
const NUM_RETRIES = 3;

async function test() {
  let i = 0;
  for (i = 0; i < NUM_RETRIES; i++) {
    try {
      await superagent.get("http://baidu.com");
      console.log("成功了");
      break;
    } catch (e) {}
  }
  console.log(i);
}

test();
